<?php	
	if($_POST["enviar"] && !empty($_FILES))
	{
		include_once "../../includes/constantes.php";
		include_once "../../includes/conectar.php";
		include_once "../../includes/funcoes.php";
		include_once "../../classes/classePadrao.php";
		include_once "../../classes/classeUpload.php";
		include_once "../../classes/classeGaleria.php";
		
		$objUpload = new classeUpload($_FILES["Filedata"], "../" .  pathUploadImagesGaleria . $_POST["cd_galeria"] . "/");
		$objUpload->arrayExtsAceitas = array("jpg", "bmp", "png", "gif");
		$objUpload->postfix = date("His");
	
		$objUpload->efetuarUpload();
		$erroImagem = $objUpload->erro;
		
		$objGaleria = new classeGaleria($conexao);
		if(!$erroImagem && $objUpload->efetuouUpload)
		{
			$objGaleria->imagem = $objUpload->newFileName;
		}
		$objGaleria->cd_galeria = $_POST["cd_galeria"];
		if(!$erroImagem)
		{
			if ($objGaleria->inserirFoto())
			{
				criaImagemPequena("../" . pathUploadImagesGaleria . $_POST["cd_galeria"] . "/" . $objUpload->newFileName, maxWidthFotoGaleria, maxHeightFotoGaleria, 
								  "../" . pathUploadImagesGaleria . $_POST["cd_galeria"] . "/" . "t" . $objUpload->newFileName, 1);
				echo "1";
			}		
		}
	}
?>